package com.cskaoyan.converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @program: project-market
 * @description: 时间格式转换器
 * @author: fish-team
 * @create: 2021-11-29 22:51
 **/
@Component
public class DateConverter implements Converter<String, Date> {
    @Override
    public Date convert(String value) {
        Date parse = null;

        try {
            parse = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return parse;
    }
}
